<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />


</head>

<body>
    <header class="aui-bar aui-bar-nav aui-bar-light" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left" style="color:#ff4285;"></span>
        </a>
        <div class="aui-title" style="color:#ff4285;">支付宝绑定</div>

    </header>
<footer class="aui-bar aui-bar-tab" id="footer" style="background:#ff4285;color:#fff;line-height:55px;" onclick="fnSubmitBindAlipy()">
        <div>点击绑定支付宝</div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        initEventListenner(); //退出键添加提示框
        //fnGetAlipayBind();
        fnOpenFrame();
};

    function fnOpenFrame() {
        var header = $api.byId('header');
        $api.fixStatusBar($api.dom('header'));
        api.setStatusBarStyle({
            style: 'dark',
           color:'transparent'
        });
        var headerH = $api.offset(header).h;
      var footer = $api.byId('footer');
      var footerH = $api.offset(footer).h;
        api.openFrame({
            name: 'alipay_bind_frame',
            url: './alipay_bind_frame.html',
            rect: {
                x: 0,
                y: headerH,
                w: 'auto',
                h: api.winHeight - footerH - headerH,
            },

            bounces: true
        });

    }
    function fnSubmitBindAlipy(){
      var SubmitVal = 'fnSubmitBindAlipyVal();';
        api.execScript({
            frameName: 'alipay_bind_frame',
            script: SubmitVal
        });
    }



    function initEventListenner() {

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.confirm({
                title: '提示',
                msg: '是否退出应用',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret.buttonIndex == 1) {
                    api.closeWidget({
                        silent: true
                    });
                }
            });
        });
    };

    function fnGetAlipayBind() {
        var userInfo = $api.getStorage("userInfo");
        var random = userInfo.random;
        var userid = userInfo.userid;
        api.ajax({
            url: SITE_URL+'index.php?m=api&c=appnew&a=cash_account_info',
            method: 'POST',
            data: {
                values: {
                    "userid": userid,
                    "random": random
                }
            }
        }, function(ret, err) {
        //  alert(JSON.stringify(ret));
            //获取绑定支付宝之后的参数
            if (ret.status == 1) {
                //把数据分配到模板上面
                fnUpdataAlipayBind(ret.data);

            } else {

            }

        })
    }
    //更新数据到模板
    function fnUpdataAlipayBind(data) {

    }
</script>

</html>
